package com.haoshuang.zhouzhoubang.ui.adapter

import android.widget.ImageView
import android.widget.TextView
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ItemMemberGroupUserBinding
import com.haoshuang.zhouzhoubang.model.bean.TeamGroupBean
import com.haoshuang.zhouzhoubang.ui.dialog.BjDialog3
import com.lxj.xpopup.XPopup
import com.makeramen.roundedimageview.RoundedImageView
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.view.clickWithTrigger
import com.mufeng.libs.utils.view.gone
import com.mufeng.libs.utils.view.load
import com.mufeng.libs.utils.view.visible

/**
 *
 */
class MemberGroupUserAdapter(data: MutableList<TeamGroupBean.Member>) :
    BaseBindingQuickAdapter<TeamGroupBean.Member, ItemMemberGroupUserBinding>(data) {


    override fun onBindViewHolder(
        holder: BaseBindingHolder,
        position: Int,
        item: TeamGroupBean.Member?
    ) {

        holder.getViewBinding<ItemMemberGroupUserBinding>().apply {
            val tvName = holder.getView<TextView>(R.id.tvName)
            val tvSde = holder.getView<TextView>(R.id.tvSde)
            val textView28 = holder.getView<TextView>(R.id.textView28)
            val textView26 = holder.getView<TextView>(R.id.textView26)
            val tvTime = holder.getView<TextView>(R.id.tvTime)
            val tvService = holder.getView<TextView>(R.id.tvService)
            val ivCheck = holder.getView<ImageView>(R.id.ivCheck)
            val tvMore = holder.getView<TextView>(R.id.tvMore)
            val tvDj = holder.getView<TextView>(R.id.tvDj)

            if (item?.work_status==1){

                textView26.visible()
                textView28.gone()
            }else{
                textView26.gone()
                textView28.visible()
            }
            val cate_name = item?.service_names?.split(",")?.filter { it.isNotEmpty() }?.toMutableList()
            if (cate_name?.isNotEmpty() == true) {
                tvService.text = cate_name[0]
            }
            if ((cate_name?.size ?:0)>1){
                tvMore.visible()
            }else{
                tvMore.gone()
            }
            tvMore.clickWithTrigger {
                XPopup.Builder(context)
                    .asCustom(BjDialog3(context, (cate_name?: arrayListOf()) as ArrayList<String>) {

                    })
                    .show()
            }

            val roundedImageView2 = holder.getView<RoundedImageView>(R.id.roundedImageView2)
            tvName.text = item?.nickname
            tvDj.text = "冻结金额："+item?.frozen_money
            tvTime.text ="加入时间：${item?.add_time}"
            roundedImageView2.load(item?.avatar, R.mipmap.rl)
        }

    }


}
